import Vue from 'vue'
import Vant from 'vant';
import App from './App.vue'
import router from './router'
import store from './store'
import 'lib-flexible'  // 根据 dpr，设置缩放比例
import './assets/css/var.less'
import 'vant/lib/index.css';

Vue.use(Vant);
Vue.config.productionTip = false

// vue 实例创建前，初始化数据
store.commit('init_data')

// 网页关闭前保存数据
window.onunload = () => {
    const shopping_cart = store.state.shopping_cart
    localStorage.setItem('shopping_cart', JSON.stringify(shopping_cart))
    const search_words = store.state.search_words
    localStorage.setItem('search_words', JSON.stringify(search_words))
}

new Vue({
    router,
    store,
    render: h => h(App)
}).$mount('#app')
